package cn.wolfcode.productServer.web.controller;

import cn.wolfcode.productServer.domain.Product;
import cn.wolfcode.productServer.service.IProductService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @ClassName ProductController
 * @Author VCR
 * @Date 2021/12/21 13:30
 * @Version 1.0
 */
@RestController
@RequestMapping("product")
@Slf4j
public class ProductController {

    @Autowired
    private IProductService productService;

    @Value("${server.port}")
    private String port;

    @RequestMapping("/get")
    public Product get(Long id) {
        log.info("调用商品服务的表现层Controller");
        // 睡3s检测feign的超时机制
        /*try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }*/
        Product product = productService.get(id);
        product.setPname(product.getPname() + ",data from" + port);
        return product;
    }
}
